package com.yh.patterns.factory.static_factory;


import com.yh.patterns.factory.static_factory.impl.AmericanCoffee;
import com.yh.patterns.factory.static_factory.impl.LatteCoffee;

/**
 * @Auther:云尚学Java
 * 简单咖啡工厂类、用来生产咖啡
 */
public  class SimpleCoffeeFactory {
    public static Coffee createCoffee(String type){
        //1.声明Coffee类型的变量，根据不同类型创建不同的coffee子类对象
        Coffee coffee=null;
        if("american".equals(type)){
            coffee=new AmericanCoffee();
        }else if("latte".equals(type)){
            coffee=new LatteCoffee();
        }else {
            throw new RuntimeException("对不起，您点的咖啡不存在");
        }
        return coffee;
    }
}
